#!/bin/csh -f
# call as: do_it 'runpcsplit $x'
# first make a subdirectory pc with: do_it 'mkdir pc'

#cd pcr
cd pc

mkdir split
cd split

source $prodir/setup.scr
source $aquaroot/aqsetup

splitpdb ../../$1.pdb
set NOSPLIT = $status

if ( $NOSPLIT ) then
    set list = ../../$1.pdb
else
    set list = (`\ls *.pdb`)
endif
foreach x ( $list )
    set fil = $x:t
    qproject tmp
    qwhat set batch on read pdb $x - select ../../ranges_paper set coordout pdb write selSet $fil quit
#    qwhat set batch on read pdb $x - set coordout pdb write $fil quit
    if ( $status ) exit
    procheck $fil 2.0
    \rm *.ps
    set proj = `$AQUABINDIR/getproj $x`
    pcsplitout $proj.out > $proj.outtail
    pcsplitout2 $proj.out > $proj.outhead
end

grep cis *.out | grep -v Number > ../$1.cis
\mv *.sum *.outtail ..
\mv *.outhead ..
cd ..
gzip *.out*
\rm -r split

